package com.gyh.thymeleaf.service.impl;

import com.gyh.thymeleaf.entity.User;
import com.gyh.thymeleaf.entity.UserExample;
import com.gyh.thymeleaf.mapper.UserMapper;
import com.gyh.thymeleaf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author gyhstart
 * @create 2020/6/8 - 18:05
 **/

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> selectList() {
        //UserExample userExample = new UserExample();
        return userMapper.selectByExample(null);
    }

    /**
     * 登录验证
     * @param user
     * @return
     */
    @Override
    public List<User> login(User user) {
        UserExample userExample = new UserExample();
        UserExample.Criteria criteria = userExample.createCriteria();
        criteria.andNameEqualTo(user.getName());
        criteria.andPasswordEqualTo(user.getPassword());
        List<User> userList = userMapper.selectByExample(userExample);
        return userList;
    }
}
